<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">

    <tr>
        <th>删除</th>
        <th>编号</th>
        <th>名称</th>
        <th>价格</th>
        <th>分类</th>
        <th>库存</th>
        <th>图片</th>
        <th>说明</th>
        <th>作者</th>
        <th>已售</th>
    </tr>
    <form th:action="@{/del}" method="post" onsubmit="return validateForm()">
    <tr th:each="book:${page.list}">
        <td>
            <input type="checkbox" th:value="${book.id}" name="ids">
        </td>
        <td th:text="${book.id}"></td>
        <td th:text="${book.name}"></td>
        <td th:text="${book.price}"></td>
        <td th:text="${book.category}"></td>
        <td th:text="${book.pnum}"></td>
        <td th:text="${book.imgurl}"></td>
        <td th:text="${book.description}"></td>
        <td th:text="${book.author}"></td>
        <td th:text="${book.sales}"></td>
    </tr>
        <input type="submit" value="删除" onsubmit="return validateForm()">
    </form>
</table>
<span th:if="${page.hasPreviousPage}">
    <a th:href="@{/page(pageNum=${page.pageNum-1})}">上一页</a>
</span>
<span th:each="p:${#numbers.sequence(1,page.pages)}">
    <a  th:href="@{/page(pageNum=${p})}" th:text="${p}" ></a>
</span>
<span th:if="${page.hasNextPage}">
    <a th:href="@{/page(pageNum=${page.pageNum+1})}">下一页</a>
</span>

总页数:<span th:text="${page.pages}"></span> &nbsp;&nbsp;&nbsp;
总记录数:<span th:text="${page.total}"></span> &nbsp;&nbsp;&nbsp;
当前页记录数:<span th:text="${page.size}"></span> &nbsp;&nbsp;&nbsp;
当前页:<span th:text="${page.pageNum}"></span>
</body>

<script src="/js/jquery.js"></script>
<script>
    function validateForm(){
        if ($("input[name='ids']:checked").length==0){
            alert("必须选择一个")
            return false;
        }
        if(confirm("确定要删除吗")){
            alert("删除成功")
        }else {
            alert("已取消删除")
            return false
        }
    }
</script>
</html>